SwiftUI の TabView の中の UIViewControllerRepresentable が present するとレイアウトが崩れる
- 一瞬 UINavigationBar の高さがおかしく (Large Title みたいな高さに) なる
- さらに、 present した VC を閉じると、元の画面のレイアウトが崩れる。
TabViewに入れていた View がTabView&UINavigationControllerの外までフルスクリーンで表示されて、裏側に回り込んでしまう
- TabView に入れてないと崩れないということがわかった。
- 画面構成は以下の通り
- SwiftUI
View>TabView>UIViewControllerRepresentable>UINavigationController(presented as.fullScreenmodal)
- SwiftUI
SwiftUIのTabViewでUIKitと連携する時の罠|TAAT これかもしれない- これだとしたら原因分からないの気持ち悪い
- 治らなかった
- FB12795690: The lifecycle of a UIViewControllerRepresentable inside a TabView with a PageTabViewStyle is not being called correctly. · Issue #411 · feedback-assistant/reports · GitHub これ踏んだかなぁ
UIViewControllerRepresentableinTabViewがすべての元凶な感じがする。- 結局 VC から NC を present しないようにした
- Before:
- SwiftUI
View TabViewUIViewControllerRepresentableUINavigationController(presented as.fullScreenmodal)
- SwiftUI
- After:
- SwiftUI
View TabView- SwiftUI
View(作り直した) UINavigationController(↑ の SwiftUI から.fullScreenCoverで表示)
- SwiftUI
- Before:
- これだったらレイアウトは崩れなかった